import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import local_set from '@dfeidao/atom-web/local/set';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import _show from '@dfeidao/atom-web/ui/show';
import { spaceid } from '../../atom/config';
import P01 from './P01';
// 选择控制点弹窗显示
export default async function a001(fd: IFeidaoAiBrowserComponent, args: { package_no: string, codes?: [], sort: string }) {
	local_set(fd, 'sort', args.sort);
	// 构建查询条件
	const filter = {} as { code: {}, package_no: string, productid: string; };
	filter.productid = spaceid;

	if (args.package_no) {
		filter.package_no = args.package_no;
	}
	if (args.codes.length > 0) {
		filter.code = { $nin: args.codes };
	}
	// 查询
	const res = await nodejs<{ dataArray: Array<{}>, count: number, page_no: number, page_size: number }>('function-definition/zj-000005/s001', { filter });
	// 渲染数据
	if (res.count > 0) {
		fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="P01"]').classList.remove('display-n');
		fd.data.node.querySelector<HTMLDivElement>('[wushujv]').classList.add('display-n');
		render(fd, res, P01, 'P01', 'inner');
	} else {
		// 如果没数据 展示空蒙版
		fd.data.node.querySelector<HTMLDivElement>('[wushujv]').classList.remove('display-n');
		render(fd, {}, P01, 'P01', 'inner');
		fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="P01"]').classList.add('display-n');
	}
	_show(fd.data.node);
}
